package com.veng.springbootdemo.rabbit;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class RabbitSender {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 发送到 名为 directExchange 的交换机，路由键为 directRouting，发送至与该路由键绑定的队列
     */
    public void send(){
        String context = "hello" + new Date();
        this.rabbitTemplate.convertAndSend("directExchange","directRouting",context);
    }
}
